#!/bin/bash
set -e # fail on errors

# Redirect stderr -> stdout
exec 2>&1

cd <%= node['postgresql']['dir'] %>

exec chpst -P \
  -U <%= node['postgresql']['username'] %>:<%= node['postgresql']['group'] %> \
  -u <%= node['postgresql']['username'] %>:<%= node['postgresql']['group'] %> \
  /opt/gitlab/embedded/bin/repmgrd -f <%= node['postgresql']['dir'] %>/repmgr.conf
